<html>
<head>

	<style type="text/css" title="currentStyle" media="screen">
		@import "vtes_exp.css";
	</style>

	<script type="text/javascript">
	<!--
	function popup(mylink, windowname) {
		if (! window.focus)return true;
		var href;
		if (typeof(mylink) == 'string')
		   href=mylink;
		else
		   href=mylink.href;
		window.open(href, windowname, 'width=240,height=320,scrollbars=no');
			return false;
		}
	//-->
	</script>

</head>
<body>
<pre>main</pre>

<?php
// session_start();

if (isset($_POST['submitted']) && $_POST['submitted'] == 'submitted')
    $reset = false;
else
	$reset = true;
?>

<pre>leftbar</pre>

<h1>The VTES Explorer</h1>/

<form action="main.php" method="post">

<div id="left_side">

<div id="search_button">
    <input type="submit" value="Refresh" />
    <input type="checkbox" name="thumbs" value="1"<?php if ($_POST["thumbs"] == "1") echo ' checked="checked"'; ?> /> Thumbs<br>
    <input type="hidden" name="submitted" value="submitted" />
</div>

<div id="per_page">
    <h2>Results per page</h2>
    <select name="per">
    <option value="50" <?php if ($reset || $_POST["per"] == "50") echo ' selected="selected"'; ?> >50</option>
    <option value="100" <?php if ($_POST["per"] == "100") echo ' selected="selected"'; ?> >100</option>
    <option value="200" <?php if ($_POST["per"] == "200") echo ' selected="selected"'; ?> >200</option>
    <option value="1800" <?php if ($_POST["per"] == "1800") echo ' selected="selected"'; ?> >all</option>
    </select><br>
</div>

<div id="card_type">
    <h2>Card Type</h2>
    <input type="checkbox" name="master" value="1"<?php if ($reset || $_POST["master"] == "1") echo ' checked="checked"'; ?> /> Master<br>
    <input type="checkbox" name="combat" value="1"<?php if ($reset || $_POST["combat"] == "1") echo ' checked="checked"'; ?> /> Combat<br>
    <input type="checkbox" name="action" value="1"<?php if ($reset || $_POST["action"] == "1") echo ' checked="checked"'; ?> /> Action<br>
    <input type="checkbox" name="actionmod" value="1"<?php if ($reset || $_POST["actionmod"] == "1") echo ' checked="checked"'; ?> /> Action Modifier<br>
    <input type="checkbox" name="political" value="1"<?php if ($reset || $_POST["political"] == "1") echo ' checked="checked"'; ?> /> Political Action<br>
    <input type="checkbox" name="reaction" value="1"<?php if ($reset || $_POST["reaction"] == "1") echo ' checked="checked"'; ?> /> Reaction<br>
    <input type="checkbox" name="equipment" value="1"<?php if ($reset || $_POST["equipment"] == "1") echo ' checked="checked"'; ?> /> Equipment<br>
    <input type="checkbox" name="ally" value="1"<?php if ($reset || $_POST["ally"] == "1") echo ' checked="checked"'; ?> /> Ally<br>
    <input type="checkbox" name="retainer" value="1"<?php if ($reset || $_POST["retainer"] == "1") echo ' checked="checked"'; ?> /> Retainer<br>
    <input type="checkbox" name="event" value="1"<?php if ($reset || $_POST["event"] == "1") echo ' checked="checked"'; ?> /> Event<br>
    <input type="checkbox" name="power" value="1"<?php if ($reset || $_POST["power"] == "1") echo ' checked="checked"'; ?> /> Power<br>
    <input type="checkbox" name="conviction" value="1"<?php if ($reset || $_POST["conviction"] == "1") echo ' checked="checked"'; ?> /> Conviction<br>
    <input type="checkbox" name="vampire" value="1"<?php if ($reset || $_POST["vampire"] == "1") echo ' checked="checked"'; ?> /> Vampire<br>
    <input type="checkbox" name="imbued" value="1"<?php if ($reset || $_POST["imbued"] == "1") echo ' checked="checked"'; ?> /> Imbued<br>
</div>

<!--
<div id="expansions">
    <h2>Expansions</h2>
    <input type="checkbox" name="jyh" value="1"<?php if ($reset || $_POST["jyh"] == "1") echo ' checked="checked"'; ?> /> Jyhad<br>
    <input type="checkbox" name="vts" value="1"<?php if ($reset || $_POST["vts"] == "1") echo ' checked="checked"'; ?> /> V:TES<br>
    <input type="checkbox" name="ds" value="1"<?php if ($reset || $_POST["ds"] == "1") echo ' checked="checked"'; ?> /> Dark Sovereigns<br>
    <input type="checkbox" name="ah" value="1"<?php if ($reset || $_POST["ah"] == "1") echo ' checked="checked"'; ?> /> Ancient Hearts<br>
    <input type="checkbox" name="sab" value="1"<?php if ($reset || $_POST["sab"] == "1") echo ' checked="checked"'; ?> /> Sabbat<br>
    <input type="checkbox" name="sbw" value="1"<?php if ($reset || $_POST["sbw"] == "1") echo ' checked="checked"'; ?> /> Sabbat War<br>
    <input type="checkbox" name="fn" value="1"<?php if ($reset || $_POST["fn"] == "1") echo ' checked="checked"'; ?> /> Final Nights<br>
    <input type="checkbox" name="bld" value="1"<?php if ($reset || $_POST["bld"] == "1") echo ' checked="checked"'; ?> /> Bloodlines<br>
    <input type="checkbox" name="cam" value="1"<?php if ($reset || $_POST["cam"] == "1") echo ' checked="checked"'; ?> /> Camarilla Edition<br>
    <input type="checkbox" name="an" value="1"<?php if ($reset || $_POST["an"] == "1") echo ' checked="checked"'; ?> /> Anarchs<br>
    <input type="checkbox" name="bh" value="1"<?php if ($reset || $_POST["bh"] == "1") echo ' checked="checked"'; ?> /> Black Hand<br>
    <input type="checkbox" name="geh" value="1"<?php if ($reset || $_POST["geh"] == "1") echo ' checked="checked"'; ?> /> Gehenna<br>
    <input type="checkbox" name="ten" value="1"<?php if ($reset || $_POST["ten"] == "1") echo ' checked="checked"'; ?> /> Tenth Anniversary<br>
    <input type="checkbox" name="kmw" value="1"<?php if ($reset || $_POST["kmw"] == "1") echo ' checked="checked"'; ?> /> Kindred Most Wanted<br>
    <input type="checkbox" name="lob" value="1"<?php if ($reset || $_POST["lob"] == "1") echo ' checked="checked"'; ?> /> Legacies of Blood<br>
    <input type="checkbox" name="nor" value="1"<?php if ($reset || $_POST["nor"] == "1") echo ' checked="checked"'; ?> /> Nights of Reckoning<br>
    <input type="checkbox" name="3rd" value="1"<?php if ($reset || $_POST["3rd"] == "1") echo ' checked="checked"'; ?> /> Third Edition<br>
    <input type="checkbox" name="pro" value="1"<?php if ($reset || $_POST["pro"] == "1") echo ' checked="checked"'; ?> /> Promo<br>
</div>
-->

<div id="clans_camarilla">
    <h2>Clans (not hooked up)</h2>
    <h3>Camarilla</h3>
    Brujah <input type="checkbox" name="bru" value="1"<?php if ($reset || $_POST["bru"] == "1") echo ' checked="checked"'; ?> /><br>
    Malkavian <input type="checkbox" name="mal" value="1"<?php if ($reset || $_POST["mal"] == "1") echo ' checked="checked"'; ?> /><br>
    Nosferatu <input type="checkbox" name="nos" value="1"<?php if ($reset || $_POST["nos"] == "1") echo ' checked="checked"'; ?> /><br>
    Toreador <input type="checkbox" name="tor" value="1"<?php if ($reset || $_POST["tor"] == "1") echo ' checked="checked"'; ?> /><br>
    Tremere <input type="checkbox" name="tre" value="1"<?php if ($reset || $_POST["tre"] == "1") echo ' checked="checked"'; ?> /><br>
    Ventrue <input type="checkbox" name="ven" value="1"<?php if ($reset || $_POST["ven"] == "1") echo ' checked="checked"'; ?> /><br>
    Caitiff <input type="checkbox" name="cai" value="1"<?php if ($reset || $_POST["cai"] == "1") echo ' checked="checked"'; ?> /><br>
</div>

<div id="clans_sabbat">
    <h3>Sabbat</h3>
    Brujah antitribu <input type="checkbox" name="bra" value="1"<?php if ($reset || $_POST["bra"] == "1") echo ' checked="checked"'; ?> /><br>
    Gangrel antitribu <input type="checkbox" name="gaa" value="1"<?php if ($reset || $_POST["gaa"] == "1") echo ' checked="checked"'; ?> /><br>
    Lasombra <input type="checkbox" name="las" value="1"<?php if ($reset || $_POST["las"] == "1") echo ' checked="checked"'; ?> /><br>
    Malkavian antitribu <input type="checkbox" name="maa" value="1"<?php if ($reset || $_POST["maa"] == "1") echo ' checked="checked"'; ?> /><br>
    Nosferatu antitribu <input type="checkbox" name="noa" value="1"<?php if ($reset || $_POST["noa"] == "1") echo ' checked="checked"'; ?> /><br>
    Toreador antitribu <input type="checkbox" name="toa" value="1"<?php if ($reset || $_POST["toa"] == "1") echo ' checked="checked"'; ?> /><br>
    Tremere antitribu <input type="checkbox" name="tra" value="1"<?php if ($reset || $_POST["tra"] == "1") echo ' checked="checked"'; ?> /><br>
    Tzimisce <input type="checkbox" name="tzm" value="1"<?php if ($reset || $_POST["tzm"] == "1") echo ' checked="checked"'; ?> /><br>
    Ventrue antitribu <input type="checkbox" name="vea" value="1"<?php if ($reset || $_POST["vea"] == "1") echo ' checked="checked"'; ?> /><br>
    Pander <input type="checkbox" name="pan" value="1"<?php if ($reset || $_POST["pan"] == "1") echo ' checked="checked"'; ?> /><br>
    <h4>Bloodlines</h4>
    Ahrimanes <input type="checkbox" name="ahr" value="1"<?php if ($reset || $_POST["ahr"] == "1") echo ' checked="checked"'; ?> /><br>
    Blood Brothers <input type="checkbox" name="blb" value="1"<?php if ($reset || $_POST["blb"] == "1") echo ' checked="checked"'; ?> /><br>
    Harbingers of Skulls <input type="checkbox" name="har" value="1"<?php if ($reset || $_POST["har"] == "1") echo ' checked="checked"'; ?> /><br>
    Kiasyd <input type="checkbox" name="kia" value="1"<?php if ($reset || $_POST["kia"] == "1") echo ' checked="checked"'; ?> /><br>
    Salubri antitribu <input type="checkbox" name="saa" value="1"<?php if ($reset || $_POST["saa"] == "1") echo ' checked="checked"'; ?> /><br>
</div>

<div id="clans_independent">
    <h3>Independent</h3>
    Assamite <input type="checkbox" name="asm" value="1"<?php if ($reset || $_POST["asm"] == "1") echo ' checked="checked"'; ?> /><br>
    Followers of Set <input type="checkbox" name="fol" value="1"<?php if ($reset || $_POST["fol"] == "1") echo ' checked="checked"'; ?> /><br>
    Gangrel <input type="checkbox" name="gan" value="1"<?php if ($reset || $_POST["gan"] == "1") echo ' checked="checked"'; ?> /><br>
    Giovanni <input type="checkbox" name="gio" value="1"<?php if ($reset || $_POST["gio"] == "1") echo ' checked="checked"'; ?> /><br>
    Ravnos <input type="checkbox" name="rav" value="1"<?php if ($reset || $_POST["rav"] == "1") echo ' checked="checked"'; ?> /><br>
    <h4>Bloodlines</h4>
    Baali <input type="checkbox" name="baa" value="1"<?php if ($reset || $_POST["baa"] == "1") echo ' checked="checked"'; ?> /><br>
    Daughters of Cacophony <input type="checkbox" name="dau" value="1"<?php if ($reset || $_POST["dau"] == "1") echo ' checked="checked"'; ?> /><br>
    Nagaraja <input type="checkbox" name="nag" value="1"<?php if ($reset || $_POST["nag"] == "1") echo ' checked="checked"'; ?> /><br>
    Salubri <input type="checkbox" name="sal" value="1"<?php if ($reset || $_POST["sal"] == "1") echo ' checked="checked"'; ?> /><br>
    Samedi <input type="checkbox" name="sam" value="1"<?php if ($reset || $_POST["sam"] == "1") echo ' checked="checked"'; ?> /><br>
    True Brujah <input type="checkbox" name="tru" value="1"<?php if ($reset || $_POST["tru"] == "1") echo ' checked="checked"'; ?> /><br>
</div>

<?php
echo '<pre>';
foreach ($_POST as $key => $value) {
	echo '$_POST'."[$key]={$value}\n";
	}
echo '</pre>';
?>

</div>


<div id="card_list_super"><div id="card_list">

<table border="1" cellspacing="0" cellpadding="0">

<tr>
    <th class="title">Name</th>
    <th class="title">Type</th>
    <th class="title">Clan</th>
    <th class="title">J</th>
    <th class="title">V</th>
    <th class="title">D</th>
    <th class="title">A</th>
    <th class="title">S</th>
    <th class="title">Sw</th>
    <th class="title">F</th>
    <th class="title">Bl</th>
    <th class="title">C</th>
    <th class="title">An</th>
    <th class="title">Bh</th>
    <th class="title">G</th>
    <th class="title">T</th>
    <th class="title">K</th>
    <th class="title">L</th>
    <th class="title">N</th>
    <th class="title">3</th>
    <th class="title">Sc</th>
    <th class="title">Pr</th>
    <th class="title">Dm</th>
</tr>

<tr><td class="title">&nbsp;</td>
    <td class="title"><select class="title_type" name="type">
        <option value="all" <?php if ($reset || $_POST["type"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="master" <?php if ($_POST["type"] == "master") echo ' selected="selected"'; ?> >Master</option>
        <option value="combat" <?php if ($_POST["type"] == "combat") echo ' selected="selected"'; ?> >Combat</option>
        <option value="action" <?php if ($_POST["type"] == "action") echo ' selected="selected"'; ?> >Action</option>
        <option value="actionmod" <?php if ($_POST["type"] == "actionmod") echo ' selected="selected"'; ?> >Action Modifier</option>
        <option value="reaction" <?php if ($_POST["type"] == "reaction") echo ' selected="selected"'; ?> >Reaction</option>
        <option value="political" <?php if ($_POST["type"] == "political") echo ' selected="selected"'; ?> >Political Action</option>
        <option value="equipment" <?php if ($_POST["type"] == "equipment") echo ' selected="selected"'; ?> >Equipment</option>
        <option value="ally" <?php if ($_POST["type"] == "ally") echo ' selected="selected"'; ?> >Ally</option>
        <option value="retainer" <?php if ($_POST["type"] == "retainer") echo ' selected="selected"'; ?> >Retainer</option>
        <option value="event" <?php if ($_POST["type"] == "event") echo ' selected="selected"'; ?> >Event</option>
        <option value="power" <?php if ($_POST["type"] == "power") echo ' selected="selected"'; ?> >Power</option>
        <option value="conviction" <?php if ($_POST["type"] == "conviction") echo ' selected="selected"'; ?> >Conviction</option>
        <option value="vampire" <?php if ($_POST["type"] == "vampire") echo ' selected="selected"'; ?> >Vampire</option>
        <option value="imbued" <?php if ($_POST["type"] == "imbued") echo ' selected="selected"'; ?> >Imbued</option>
    </select></td>
    <td class="title"><select class="title_clan" name="clan">
        <option value="all" <?php if ($reset || $_POST["clan"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="none" <?php if ($_POST["clan"] == "none") echo ' selected="selected"'; ?> >none</option>
        <optgroup label="Camarilla">
            <option value="brujah" <?php if ($_POST["clan"] == "brujah") echo ' selected="selected"'; ?> >Brujah</option>
            <option value="caitiff" <?php if ($_POST["clan"] == "caitiff") echo ' selected="selected"'; ?> >Caitiff</option>
            <option value="malkavian" <?php if ($_POST["clan"] == "malkavian") echo ' selected="selected"'; ?> >Malkavian</option>
            <option value="nosferatu" <?php if ($_POST["clan"] == "nosferatu") echo ' selected="selected"'; ?> >Nosferatu</option>
            <option value="toreador" <?php if ($_POST["clan"] == "toreador") echo ' selected="selected"'; ?> >Toreador</option>
            <option value="tremere" <?php if ($_POST["clan"] == "tremere") echo ' selected="selected"'; ?> >Tremere</option>
            <option value="ventrue" <?php if ($_POST["clan"] == "ventrue") echo ' selected="selected"'; ?> >Ventrue</option>
        </optgroup>
        <optgroup label="Sabbat">
            <option value="brujah antitribu" <?php if ($_POST["clan"] == "brujah antitribu") echo ' selected="selected"'; ?> >Brujah <i>antitribu</i></option>
            <option value="gangrel antitribu" <?php if ($_POST["clan"] == "gangrel antitribu") echo ' selected="selected"'; ?> >Gangrel <i>antitribu</i></option>
            <option value="lasombra" <?php if ($_POST["clan"] == "lasombra") echo ' selected="selected"'; ?> >Lasombra</option>
            <option value="malkavian antitribu" <?php if ($_POST["clan"] == "malkavian antitribu") echo ' selected="selected"'; ?> >Malkavian <i>antitribu</i></option>
            <option value="nosferatu antitribu" <?php if ($_POST["clan"] == "nosferatu antitribu") echo ' selected="selected"'; ?> >Nosferatu <i>antitribu</i></option>
            <option value="pander" <?php if ($_POST["clan"] == "pander") echo ' selected="selected"'; ?> >Pander</option>
            <option value="toreador antitribu" <?php if ($_POST["clan"] == "toreador antitribu") echo ' selected="selected"'; ?> >Toreador <i>antitribu</i></option>
            <option value="tremere antitribu" <?php if ($_POST["clan"] == "tremere antitribu") echo ' selected="selected"'; ?> >Tremere <i>antitribu</i></option>
            <option value="tzimisce" <?php if ($_POST["clan"] == "tzimisce") echo ' selected="selected"'; ?> >Tzimisce</option>
            <option value="ventrue antitribu" <?php if ($_POST["clan"] == "ventrue antitribu") echo ' selected="selected"'; ?> >Ventrue <i>antitribu</i></option>
        </optgroup>
        <optgroup label="Laibon">
            <option value="akunanse" <?php if ($_POST["clan"] == "akunanse") echo ' selected="selected"'; ?> >Akunanse</option>
            <option value="guruhi" <?php if ($_POST["clan"] == "guruhi") echo ' selected="selected"'; ?> >Guruhi</option>
            <option value="ishtarri" <?php if ($_POST["clan"] == "ishtarri") echo ' selected="selected"'; ?> >Ishtarri</option>
            <option value="osebo" <?php if ($_POST["clan"] == "osebo") echo ' selected="selected"'; ?> >Osebo</option>
        </optgroup>
        <optgroup label="Independent">
            <option value="abomination" <?php if ($_POST["clan"] == "abomination") echo ' selected="selected"'; ?> >Abomination</option>
            <option value="assamite" <?php if ($_POST["clan"] == "assamite") echo ' selected="selected"'; ?> >Assamite</option>
            <option value="followers of set" <?php if ($_POST["clan"] == "follows of set") echo ' selected="selected"'; ?> >Followers of Set</option>
            <option value="gangrel" <?php if ($_POST["clan"] == "gangrel") echo ' selected="selected"'; ?> >Gangrel</option>
            <option value="giovanni" <?php if ($_POST["clan"] == "giovanni") echo ' selected="selected"'; ?> >Giovanni</option>
            <option value="ravnos" <?php if ($_POST["clan"] == "ravnos") echo ' selected="selected"'; ?> >Ravnos</option>
        </optgroup>
        <optgroup label="Bloodlines - Sabbat">
            <option value="ahrimanes" <?php if ($_POST["clan"] == "ahrimanes") echo ' selected="selected"'; ?> >Ahrimanes</option>
            <option value="blood brothers" <?php if ($_POST["clan"] == "blood brothers") echo ' selected="selected"'; ?> >Blood Brothers</option>
            <option value="harbingers of skulls" <?php if ($_POST["clan"] == "harbingers of skulls") echo ' selected="selected"'; ?> >Harbingers of Skulls</option>
            <option value="kiasyd" <?php if ($_POST["clan"] == "kiasyd") echo ' selected="selected"'; ?> >Kiasyd</option>
            <option value="salubri antitribu" <?php if ($_POST["clan"] == "salubri antitribu") echo ' selected="selected"'; ?> >Salubri <i>antitribu</i></option>
        </optgroup>
        <optgroup label="Bloodlines - Independent">
            <option value="baali" <?php if ($_POST["clan"] == "baali") echo ' selected="selected"'; ?> >Baali</option>
            <option value="daughters of cacophony" <?php if ($_POST["clan"] == "daughters of cacophony") echo ' selected="selected"'; ?> >Daughters of Cacophony</option>
            <option value="gargoyle" <?php if ($_POST["clan"] == "gargoyle") echo ' selected="selected"'; ?> >Gargoyle</option>
            <option value="nagaraja" <?php if ($_POST["clan"] == "nagaraja") echo ' selected="selected"'; ?> >Nagaraja</option>
            <option value="salubri" <?php if ($_POST["clan"] == "salubri") echo ' selected="selected"'; ?> >Salubri</option>
            <option value="samedi" <?php if ($_POST["clan"] == "samedi") echo ' selected="selected"'; ?> >Samedi</option>
            <option value="true brujah" <?php if ($_POST["clan"] == "true brujah") echo ' selected="selected"'; ?> >True Brujah</option>
        </optgroup>
        <optgroup label="Imbued">
            <option value="avenger" <?php if ($_POST["clan"] == "avenger") echo ' selected="selected"'; ?> >Avenger</option>
            <option value="defender" <?php if ($_POST["clan"] == "defender") echo ' selected="selected"'; ?> >Defender</option>
            <option value="innocent" <?php if ($_POST["clan"] == "innocent") echo ' selected="selected"'; ?> >Innocent</option>
            <option value="judge" <?php if ($_POST["clan"] == "judge") echo ' selected="selected"'; ?> >Judge</option>
            <option value="martyr" <?php if ($_POST["clan"] == "martyr") echo ' selected="selected"'; ?> >Martyr</option>
            <option value="redeemer" <?php if ($_POST["clan"] == "redeemer") echo ' selected="selected"'; ?> >Redeemer</option>
            <option value="visionary" <?php if ($_POST["clan"] == "visionary") echo ' selected="selected"'; ?> >Visionary</option>
        </optgroup>
    </select></td>
    <td class="title"><select class="title" name="jyh">
        <option value="all" <?php if ($reset || $_POST["jyh"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["jyh"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["jyh"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["jyh"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["jyh"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="V" <?php if ($_POST["jyh"] == "V") echo ' selected="selected"'; ?> >V</option>
        <option value="none" <?php if ($_POST["jyh"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="vts">
        <option value="all" <?php if ($reset || $_POST["vts"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["vts"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["vts"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["vts"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["vts"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="V" <?php if ($_POST["vts"] == "V") echo ' selected="selected"'; ?> >V</option>
        <option value="none" <?php if ($_POST["vts"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="ds">
        <option value="all" <?php if ($reset || $_POST["ds"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["ds"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="U" <?php if ($_POST["ds"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["ds"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="V" <?php if ($_POST["ds"] == "V") echo ' selected="selected"'; ?> >V</option>
        <option value="none" <?php if ($_POST["ds"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="ah">
        <option value="all" <?php if ($reset || $_POST["ah"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["ah"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["ah"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["ah"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["ah"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="V" <?php if ($_POST["ah"] == "V") echo ' selected="selected"'; ?> >V</option>
        <option value="none" <?php if ($_POST["ah"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="sab">
        <option value="all" <?php if ($reset || $_POST["sab"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["sab"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["sab"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["sab"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["sab"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="V" <?php if ($_POST["sab"] == "V") echo ' selected="selected"'; ?> >V</option>
        <option value="none" <?php if ($_POST["sab"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="sbw">
        <option value="all" <?php if ($reset || $_POST["sbw"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["sbw"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["sbw"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["sbw"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["sbw"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="P" <?php if ($_POST["sbw"] == "P") echo ' selected="selected"'; ?> >P</option>
        <option value="none" <?php if ($_POST["sbw"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="fn">
        <option value="all" <?php if ($reset || $_POST["fn"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["fn"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["fn"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["fn"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["fn"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="P" <?php if ($_POST["fn"] == "P") echo ' selected="selected"'; ?> >P</option>
        <option value="none" <?php if ($_POST["fn"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="bld">
        <option value="all" <?php if ($reset || $_POST["bld"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["bld"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["bld"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["bld"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["bld"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="none" <?php if ($_POST["bld"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="cam">
        <option value="all" <?php if ($reset || $_POST["cam"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["cam"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["cam"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["cam"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["cam"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="P" <?php if ($_POST["cam"] == "P") echo ' selected="selected"'; ?> >P</option>
        <option value="V" <?php if ($_POST["cam"] == "V") echo ' selected="selected"'; ?> >V</option>
        <option value="none" <?php if ($_POST["cam"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="an">
        <option value="all" <?php if ($reset || $_POST["an"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["an"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["an"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["an"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["an"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="none" <?php if ($_POST["an"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="bh">
        <option value="all" <?php if ($reset || $_POST["bh"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["bh"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["bh"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["bh"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["bh"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="P" <?php if ($_POST["bh"] == "P") echo ' selected="selected"'; ?> >P</option>
        <option value="none" <?php if ($_POST["bh"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="geh">
        <option value="all" <?php if ($reset || $_POST["geh"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["geh"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["geh"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["geh"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["geh"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="none" <?php if ($_POST["geh"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="ten">
        <option value="all" <?php if ($reset || $_POST["ten"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["ten"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["ten"] == "A+B") echo ' selected="selected"'; ?> >A+B</option>
        <option value="U" <?php if ($_POST["ten"] == "A") echo ' selected="selected"'; ?> >A</option>
        <option value="C" <?php if ($_POST["ten"] == "B") echo ' selected="selected"'; ?> >B</option>
        <option value="none" <?php if ($_POST["ten"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="kmw">
        <option value="all" <?php if ($reset || $_POST["kmw"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["kmw"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["kmw"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["kmw"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["kmw"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="P" <?php if ($_POST["kmw"] == "P") echo ' selected="selected"'; ?> >P</option>
        <option value="none" <?php if ($_POST["kmw"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="lob">
        <option value="all" <?php if ($reset || $_POST["lob"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["lob"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["lob"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["lob"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["lob"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="P" <?php if ($_POST["lob"] == "P") echo ' selected="selected"'; ?> >P</option>
        <option value="none" <?php if ($_POST["lob"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="nor">
        <option value="all" <?php if ($reset || $_POST["nor"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["nor"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["nor"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["nor"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["nor"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="none" <?php if ($_POST["nor"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="3rd">
        <option value="all" <?php if ($reset || $_POST["3rd"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["3rd"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["3rd"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="U" <?php if ($_POST["3rd"] == "U") echo ' selected="selected"'; ?> >U</option>
        <option value="C" <?php if ($_POST["3rd"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="P" <?php if ($_POST["3rd"] == "P") echo ' selected="selected"'; ?> >P</option>
        <option value="V" <?php if ($_POST["3rd"] == "P") echo ' selected="selected"'; ?> >V</option>
        <option value="none" <?php if ($_POST["3rd"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="soc">
        <option value="all" <?php if ($reset || $_POST["soc"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["soc"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="R" <?php if ($_POST["soc"] == "R") echo ' selected="selected"'; ?> >R</option>
        <option value="C" <?php if ($_POST["soc"] == "C") echo ' selected="selected"'; ?> >C</option>
        <option value="V" <?php if ($_POST["soc"] == "V") echo ' selected="selected"'; ?> >V</option>
        <option value="none" <?php if ($_POST["soc"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="pro">
        <option value="all" <?php if ($reset || $_POST["pro"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["pro"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="none" <?php if ($_POST["pro"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>
    <td class="title"><select class="title" name="dem">
        <option value="all" <?php if ($reset || $_POST["dem"] == "all") echo ' selected="selected"'; ?> >all</option>
        <option value="only" <?php if ($_POST["dem"] == "only") echo ' selected="selected"'; ?> >only</option>
        <option value="none" <?php if ($_POST["dem"] == "none") echo ' selected="selected"'; ?> >none</option>
    </select></td>

<!--
    <td><input type="checkbox" name="jyh" value="1"<?php if ($reset || $_POST["jyh"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="vts" value="1"<?php if ($reset || $_POST["vts"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="ds" value="1"<?php if ($reset || $_POST["ds"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="ah" value="1"<?php if ($reset || $_POST["ah"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="sab" value="1"<?php if ($reset || $_POST["sab"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="sbw" value="1"<?php if ($reset || $_POST["sbw"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="fn" value="1"<?php if ($reset || $_POST["fn"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="bld" value="1"<?php if ($reset || $_POST["bld"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="cam" value="1"<?php if ($reset || $_POST["cam"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="an" value="1"<?php if ($reset || $_POST["an"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="bh" value="1"<?php if ($reset || $_POST["bh"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="geh" value="1"<?php if ($reset || $_POST["geh"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="ten" value="1"<?php if ($reset || $_POST["ten"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="kmw" value="1"<?php if ($reset || $_POST["kmw"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="lob" value="1"<?php if ($reset || $_POST["lob"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="nor" value="1"<?php if ($reset || $_POST["nor"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="3rd" value="1"<?php if ($reset || $_POST["3rd"] == "1") echo ' checked="checked"'; ?> /></td>
    <td><input type="checkbox" name="pro" value="1"<?php if ($reset || $_POST["pro"] == "1") echo ' checked="checked"'; ?> /></td>
-->

</tr>

<!-- <th>J</th><th>V</th><th>D</th><th>A</th><th>S</th><th>Sw</th><th>F</th><th>Bl</th><th>C</th><th>An</th><th>Bh</th><th>G</th><th>T</th><th>K</th><th>L</th><th>N</th><th>3</th><th>Pr</th></tr> -->

<?php
/*
echo '$_POST';
foreach ($_POST as $key => $val)
    echo '['.$key.']=['.$val.'],';
echo '
';
*/

$expansions = array(2 => "jyh", "vts", "ds", "ah", "sab", "sbw", "fn", "bld", "cam", "an", "bh", "geh", "ten", "kmw", "lob", "nor", "3rd", "soc", "pro", "dem");

$c = 0;
$file = fopen("db_types.csv", "r");
fgetcsv($file, 1000, ",");   // ditch the first line
while  (($types[$c] = fgetcsv($file, 1000, ",")) !== FALSE) {
    $c++;
    }
fclose($file);

$c = 0;
$file = fopen("db_images.csv","r");
fgetcsv($file, 1000, ",");   // ditch the first line
while  (($images[$c] = fgetcsv($file, 1000, ",")) !== FALSE) {
    $c++;
    }
fclose($file);

$c = 0;
$file = fopen("db_rarities.csv","r");
fgetcsv($file, 1000, ",");   // ditch the first line
while  (($rarity[$c] = fgetcsv($file, 1000, ",")) !== FALSE) {
    $c++;
    }
fclose($file);

$c = 0;
foreach ($images as $idx => $card) {

    // Compare the current card type with the requested types, and filter accordingly.
    if ($reset == false) {
        switch ($types[$idx][1]) {
            case "Master":
                if ($_POST["master"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "master" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Combat":
                if ($_POST["combat"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "combat" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Combat / Reaction":
            case "Reaction / Combat":
                if ($_POST["combat"] !== "1" and $_POST["reaction"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "combat" && $_POST["type"] !== "reaction" &&  $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Action":
                if ($_POST["action"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "action" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Action / Combat":
                if ($_POST["action"] !== "1" and $_POST["combat"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "action" && $_POST["type"] !== "combat" &&  $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Action / Reaction":
                if ($_POST["action"] !== "1" and $_POST["reaction"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "action" && $_POST["type"] !== "reaction" &&  $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Action Modifier":
                if ($_POST["actionmod"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "actionmod" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Action Modifier / Combat":
            case "Combat / Action Modifier":
                if ($_POST["actionmod"] !== "1" and $_POST["combat"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "actionmod" && $_POST["type"] !== "combat" &&  $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Action Modifier / Reaction":
            case "Reaction / Action Modifier":
                if ($_POST["actionmod"] !== "1" and $_POST["reaction"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "reaction" && $_POST["type"] !== "actionmod" &&  $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Political Action":
                if ($_POST["political"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "political" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Reaction":
                if ($_POST["reaction"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "reaction" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Equipment":
                if ($_POST["equipment"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "equipment" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Ally":
                if ($_POST["ally"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "ally" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Retainer":
                if ($_POST["retainer"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "retainer" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Event":
                if ($_POST["event"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "event" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Power":
                if ($_POST["power"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "power" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Conviction":
                if ($_POST["conviction"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "conviction" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Vampire":
                if ($_POST["vampire"] !== "1")
                    continue 2;
                if ($_POST["type"] !== "vampire" && $_POST["type"] !== "all")
                    continue 2;
                break;
            case "Imbued":
                if ($_POST["imbued"] !== "1")
                    continue 2;
                 if ($_POST["type"] !== "imbued" && $_POST["type"] !== "all")
                    continue 2;
               break;
            default:
                // echo "<tr><td>Error - bad card type - [.$idx.][".$types[$idx][0]."][".$types[$idx][1]."]</td></tr>\n";
                continue 2;
            }

        if ($_POST["clan"] !== "all") {
            if ($_POST["clan"] !== strtolower($types[$idx][2])) {
                // echo "[".$_POST["clan"]."]:[".strtolower($types[$idx][2])."]\n";
                continue;
                }
            }
        
        // echo "$card[0]: ";
        foreach ($rarity[$idx] as $key => $val) {
            if ($key <= 1)  // skip the first field
                continue;
           
            $exp = $expansions[$key];
            // echo "[$key]=[$exp]:";
            // if ($key == 2) {

                if ($_POST[$exp] == "only") {
                    if ($val == " ")
                        continue 2;
                    else
                        continue ;
                    }

                // If we want all of this expansion, drop out of loop and collect it.
                if ($_POST[$exp] == "all") 
                    continue;

                // If we want none of this expansion, continue 2 will reset the main card loop.
                //
                // Note that the "null" value for these fields is " ", and that HTML eats whitespace,
                // making this difficult to detect.  Fun.
                if ($_POST[$exp] == "none") {
                    if ($val == " ") 
                        continue;
                    continue 2;
                    }

                // Now we know that we have a specific rarity selected.  Test the first letter to see
                // if it's an invalid match, and if so, reset the loop.
                
                // echo "$key, $val, ";
                else if ($_POST[$exp] !== substr($val,0,1))
                    continue 2;
                
                // We have found no reason to bail on the card, so keep it.
                else
                   continue;
            //    }
            }
        }

    // If we've made it this far, we want this card.
    $card_list[$idx] = $card;

    $c++;
    if (($reset == true && $c >= 50) || ($reset == false && $c >= $_POST["per"]))
        break;
    }
    
// Output the table we found.
foreach ($card_list as $idx => $card) {
    echo "<tr><td class=\"card_name\"><h2";
    switch (substr($rarity[$idx][1],0,1)) {
        case "R":
            echo " class=\"rare\"";
            break;
        case "U":
        case "V":
            echo " class=\"uncommon\"";
            break;
        case "C":
            echo " class=\"common\"";
            break;
        case "A":
        case "B":
        case "P":
            echo " class=\"prebuilt\"";
            break;
        case "2":   // Promos have the date in the rarity field.
            echo " class=\"promo\">";
            break;
        default:
            echo " class=\"promo\"";
            
            echo '>';
            break;
        }
    echo ">";
    if (strlen($card[0]) >= 30)
        echo "<span class=\"smaller\">";
    echo $card[0];
    if (strlen($card[0]) >= 30)
        echo "</span>";
    echo "</h2></td>";

    echo "<td class=\"card_type\"><h3>";
    if (strlen($types[$idx][1]) >= 20)
        echo "<span class=\"much_smaller\">";
    echo $types[$idx][1];
    if (strlen($types[$idx][1]) >= 20)
        echo "</span>";
    echo "</h3></td>";

    echo "<td class=\"card_clan\"><h3>";
    if (strlen($types[$idx][2]) >= 10)
        echo "<span class=\"much_smaller\">";
    echo $types[$idx][2];
    if (strlen($types[$idx][2]) >= 10)
        echo "</span>";
    echo "</h3></td>";
    
    foreach ($images[$idx] as $key => $val) {
        if ($key <= 1)  // skip the first field
            continue;
        echo '<td ';
        if ($val == '' or $val == ' ')
            echo 'class="card_blank">';
        else {
            switch (substr($rarity[$idx][$key],0,1)) {
                case "R":
                    echo 'class="card_rare">';
                    break;
                case "U":
                case "V":
                    echo 'class="card_unc">';
                    break;
                case "C":
                    echo 'class="card_common">';
                    break;
                case "A":
                case "B":
                case "P":
                    echo 'class="card_pre">';
                    break;
                case "2":   // Promos have the date in the rarity field.
                    echo 'class="card_promo">';
                    break;
                default:
                    echo '>';
                    break;
                }
            if ($val == 'x')
                echo $val;
            elseif ($val !== '' and $val !== ' ') {
                echo "<a href=\"../ebay/$val\" onClick=\"return popup(this, 'name')\")>";
                if ($_POST["thumbs"] == "1")
                    echo "<img src=\"th/".substr($val,0,-4)."_th.jpg\" border=\"0\">";
                else {
                	switch ($types[$idx][1]) {
                        case "Vampire":
                        case "Imbued":
                            if ($key == 2)
                                echo "<img src=\"th/_back_cry_jyh_th.jpg\" border=\"0\">";
                            else
                                echo "<img src=\"th/_back_cry_vts_th.jpg\" border=\"0\">";
                            break;
                        default:
                            if ($key == 2)
                                echo "<img src=\"th/_back_lib_jyh_th.jpg\" border=\"0\">";
                            else
                                echo "<img src=\"th/_back_lib_vts_th.jpg\" border=\"0\">";
                            break;
                        }
                    }
                echo "</a>";
                }
            }
        echo "</td>";
        }
    echo "</tr>\n";
    }
?>

</table>

<?php
    echo 'Number of records: '.$c.'<br>';
?>

</div></div>

</form>

</body>
</html>